<template>
  <div class="user-page">
    <div class="user">
      <img :src="info.avatar" alt="" />
      <h3>{{info.username}}</h3>
    </div>

    <!-- 记录区域 -->
    <van-grid column-num="3">
      <van-grid-item icon="clock-o" text="历史" />
      <van-grid-item icon="bookmark-o" text="收藏" to="/collect"/>
      <van-grid-item icon="thumb-circle-o" text="点赞" to="/like"/>
    </van-grid>
    <!-- 功能区域 -->
    <van-cell-group style="margin-top:20px;">
    <van-cell title="单元格" is-link />
    <van-cell title="单元格" is-link />
    <van-cell title="单元格" is-link />
    <van-cell title="退出登录" is-link @click="logOut" />
  </van-cell-group>
  </div>
</template>

<script>
import { getUserInfo } from '@/api/interview'
import { removeToken } from '@/utils/storage'
export default {
  name: 'user-page',
  data() {
    return {
      info: []
    }
  },
  methods: {
    logOut() {
      this.$toast('退出成功')
      removeToken()
      this.$router.push('/login')
    }
  },
  async created() {
    const res = await getUserInfo()
    console.log(res)
    this.info = res.data
  }

}
</script>

<style lang="less" scoped>
.user-page {
  padding: 0 10px;
  background: #f5f5f5;
  height: 100vh;
  .mt20 {
    margin-top: 20px;
  }
  .user {
    display: flex;
    padding: 20px 0;
    align-items: center;
    img {
      width: 80px;
      height: 80px;
      border-radius: 50%;
      overflow: hidden;
    }
    h3 {
      margin: 0;
      padding-left: 20px;
      font-size: 18px;
    }
  }
}
</style>
